package com.ljk.studywebsocket.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author ljk
 * @since 2023-01-07 15:25
 */
public class JSONUtil {

    private static ObjectMapper mapper = new ObjectMapper();

    public static String toJsonStr(Object data){
        try {
            return mapper.writeValueAsString(data);
        } catch (JsonProcessingException e) {
            System.err.println(e.getMessage());
            return null;
        }
    }
}
